package com.fulihui.wgj.biz.common.util;

import static com.fulihui.common.constants.PlaceholderConstants.NICK_NAME;
import com.fulihui.weixinsdk.model.TemplateItem;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * @author: Levon
 * @version: v 0.1 2018-05-18 16:54
 */
public class NickNameUtil {

    public static void replaceNickname(Map<String, TemplateItem> data, String nickname) {
        if (StringUtils.isNotBlank(nickname)) {
            data.forEach((k, v) -> {
                String content = v.getValue();
                if (content.indexOf(NICK_NAME) != -1) {
                    v.setValue(content.replaceAll(NICK_NAME, nickname));
                }
            });
        }
    }
}
